package com.example.demo.controller;


import com.example.demo.entity.Product;
import com.example.demo.entity.Student;
import com.example.demo.entity.Table;
import com.example.demo.entity.useri;
import com.example.demo.mapper.ProductDao;
import com.example.demo.mapper.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class TableController {

    @Autowired
    ProductDao product;

    @Autowired
    UserDao userDao;

    @RequestMapping("/student")
    public Student getString(){
        Student build = Student.builder().name("1").age("2").build();
        return build;
    }



    @RequestMapping("/getProduct")
    public Table<Product> getProduct(){
        Table<Product> tab = new Table<Product>();
        List<Product> products = product.selectList(null);
        tab.setData(products);

        tab.setCount(products.size());
        return  tab;
    }



    @PostMapping("/updateStudent")
    public String  getStudent(@RequestBody useri useri){
        System.out.println(useri.toString());
        int i = userDao.updateById(useri);
        return "gengxin成功";
    }
}
